package edu.info.manager.service;

import edu.info.manager.dao.StudentDao;
import edu.info.manager.domain.StudentJavaBean;

public class StudentService {
    StudentDao studentDao = new StudentDao();

    public static StudentJavaBean[] FindAllStudent() {
       StudentJavaBean stu[]= StudentDao.FindId();
       boolean flag=false;
        for (int i = 0; i < stu.length; i++) {
            StudentJavaBean st=stu[i];
            if (st!=null){
                flag=true;
                break;
            }
        }
        if(flag)
        {
            return stu;
        }
        else
        {
            return null;
        }
    }

    public  boolean UpdateStudent(String updateid, StudentJavaBean newstu) {
        return studentDao.UpdateStudent(updateid,newstu);
    }


    public boolean AddStudent(StudentJavaBean stu) {

        return studentDao.addstudent(stu);
    }

    public boolean isExists(String id) {
        StudentJavaBean stu[]=StudentDao.FindId();

        for (int i = 0; i < stu.length; i++) {
            if (stu[i]!=null&&stu[i].getId().equals(id))
            {
                return true;
            }
        }
    return false;
    }

    public boolean DeleteStudent(String delnum) {
        return studentDao.DeleteStudent(delnum);
    }
}
